import Vue from 'vue'
import VueRouter from 'vue-router'
const EditArticle=()=>import("../views/EditArticle")
const Home =() => import('../views/Home.vue')
const Notice =() => import('../views/Notice.vue')

Vue.use(VueRouter)

const routes = [
  {
    //设置默认路径为首页
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home,
    meta:{
      title: '首页'
    }
  },
  {
    path: '/feedback',
    meta: {
      title: '反馈'
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Feedback.vue')
  },
  {
    path: '/edit-article',
    meta: {
      title: '编辑'
    },
    component:EditArticle
  },
  {
    path: '/notice',
    meta: {
      title: '公告'
    },
    component:Notice
  }
]

const router = new VueRouter({
  routes,
  mode:'history',
  // linkActiveClass: 'active'
})

router.beforeEach((to,from,next)=>{
  document.title = to.matched[0].meta.title
  next()
})

export default router
